package com.yfl.logistics.mapper;

import com.yfl.logistics.pojo.TPermission;
import com.yfl.logistics.pojo.TPermissionExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface TPermissionMapper {
    @Delete({
        "delete from t_permission",
        "where permission_id = #{permissionId,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long permissionId);

    @Insert({
        "insert into t_permission (permission_id, name, ",
        "type, url, expression, ",
        "parent_id, sort)",
        "values (#{permissionId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, ",
        "#{type,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{expression,jdbcType=VARCHAR}, ",
        "#{parentId,jdbcType=BIGINT}, #{sort,jdbcType=INTEGER})"
    })
    int insert(TPermission record);

    @InsertProvider(type=TPermissionSqlProvider.class, method="insertSelective")
    int insertSelective(TPermission record);

    @SelectProvider(type=TPermissionSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="permission_id", property="permissionId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="expression", property="expression", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER)
    })
    List<TPermission> selectByExample(TPermissionExample example);

    @Select({
        "select",
        "permission_id, name, type, url, expression, parent_id, sort",
        "from t_permission",
        "where permission_id = #{permissionId,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="permission_id", property="permissionId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.VARCHAR),
        @Result(column="url", property="url", jdbcType=JdbcType.VARCHAR),
        @Result(column="expression", property="expression", jdbcType=JdbcType.VARCHAR),
        @Result(column="parent_id", property="parentId", jdbcType=JdbcType.BIGINT),
        @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER)
    })
    TPermission selectByPrimaryKey(Long permissionId);

    @UpdateProvider(type=TPermissionSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TPermission record);

    @Update({
        "update t_permission",
        "set name = #{name,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=VARCHAR},",
          "url = #{url,jdbcType=VARCHAR},",
          "expression = #{expression,jdbcType=VARCHAR},",
          "parent_id = #{parentId,jdbcType=BIGINT},",
          "sort = #{sort,jdbcType=INTEGER}",
        "where permission_id = #{permissionId,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(TPermission record);
}